-
-
Notifications
You must be signed in to change notification settings - Fork 54
FIX: missing ip settings from SDK package #390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/js/integrations/sdkinfo.ts
Outdated
let defaultPii: boolean | undefined = undefined; | ||
|
||
const client = getClient(); | ||
if (client) { | ||
const options = client?.getOptions(); | ||
defaultPii = options.sendDefaultPii; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential bug: The SdkInfo
integration caches the sendDefaultPii
option during initial setup. If Sentry.init()
is called again, the integration uses a stale value, leading to incorrect IP inference.
-
Description: The
SdkInfo
integration captures thesendDefaultPii
option value within thesetupOnce
method. BecausesetupOnce
is designed to run only once per integration lifecycle, this value becomes stale if the Sentry SDK is re-initialized with different options via a subsequentSentry.init()
call. For example, if an application initializes withsendDefaultPii: false
and later re-initializes withsendDefaultPii: true
after obtaining user consent, the event processor will continue to use the initialfalse
value. This results ininfer_ip
being incorrectly set to'never'
, causing a loss of IP address data. -
Suggested fix: To ensure the most current options are always used, move the client and option retrieval logic from
setupOnce
into theaddEventProcessor
callback. This will fetchgetClient().getOptions()
for each event, reflecting any changes from SDK re-initialization.
severity: 0.65, confidence: 0.9
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't wrong but we don't guarantee mutability of SDK options and JS has the same behaviour
(happy to leave the call up to you if you wanna change it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SDK doesn't behave well from what I tested on multiple initializations, and since the SDK is on low maintenance I'd say it's good enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Same minor concern as in capacitor but LGTM!
src/js/integrations/sdkinfo.ts
Outdated
let defaultPii: boolean | undefined = undefined; | ||
|
||
const client = getClient(); | ||
if (client) { | ||
const options = client?.getOptions(); | ||
defaultPii = options.sendDefaultPii; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't wrong but we don't guarantee mutability of SDK options and JS has the same behaviour
(happy to leave the call up to you if you wanna change it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎸
Co-authored-by: Lukas Stracke <[email protected]>
Checked that user ip wasn't being set when sendDefaultPii was set to auto |
Based on getsentry/sentry-javascript#17364
original context;
Instead of bumping o V10, the fix was patched on the current release.